import { useState } from "react";

function Child(props) {
  console.log(props);
  return (
    <div>
      <h2>{props.name + "-" + props.age}</h2>
      <button onClick={props.changeMessage}>更改</button>
    </div>
  );
}

function Fcpn() {
  let [message, setMessage] = useState("原文本");
  function handleChangeMessage() {
    setMessage("更改文本");
  }
  return (
    <div>
      <h1>这里是一个简单的函数式组件</h1>
      <Child name="fsy" age={20} changeMessage={handleChangeMessage} />
      <h2>{message}</h2>
    </div>
  );
}

export default Fcpn;
